Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Refactor MailKitClientFactory to remove semaphore and recreate a client for each connection - #2849

Merged
IEvangelist merged 1 commit into
dotnet:mainfrom
sammychinedu2ky:fix-smtp-client-disconnection-issue
Mar 21, 2025
Merged

Refactor MailKitClientFactory to remove semaphore and recreate a client for each connection#2849
IEvangelist merged 1 commit into
dotnet:mainfrom
sammychinedu2ky:fix-smtp-client-disconnection-issue

Conversation

@sammychinedu2ky

Copy link
Copy Markdown
Contributor

Summary

The initial implementation worked well in a scoped DI setup, ensuring that each web request received a fresh SMTP client. However, in an Orleans grain scenario where grains can remain active for extended periods, the SMTP client may become disconnected due to inactivity.

Describe your changes here.

  • Removed the SemaphoreSlim as it was no longer needed.
  • Ensured that a new SmtpClient instance is created for each request to prevent stale connections.

@IEvangelist IEvangelist reopened this Mar 21, 2025
@IEvangelist
IEvangelist enabled auto-merge (squash) March 21, 2025 14:45
@IEvangelist
IEvangelist merged commit bfd3177 into dotnet:main Mar 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants